package com.service;

import com.pojo.User;
import com.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;


    public boolean add(User user) {
       /* if(userMapper.select(user.getUsername())!=null) {
            System.out.println("用户已存在");
            return false;
        }*/
        //userMapper.insert(user);
        //System.out.println("用户 "+user.getUsername()+" 注册成功");
        return userMapper.insert(user);
    }

    public boolean update(User user) {
        /*if(userMapper.select(user.getUsername())!=null) {
            System.out.println("用户已存在");
            return false;
        }*/

        //System.out.println("用户 "+user.getUsername()+" 注册成功");
        return userMapper.update(user);
    }


    public User query(User user) {
        //System.out.println(333);
        User user2 = userMapper.query(user.getEmail());
        //System.out.println(4444);

        /*if (!user2.getPassword().equals(user.getPassword())) {
            System.out.println("密码错误");
            return 2;
        }*/
        //System.out.println(5555);
        return user2;
    }

    public List<User> selectAllSalesman() {
        /*if(userMapper.select(user.getUsername())!=null) {
            System.out.println("用户已存在");
            return false;
        }*/

        //System.out.println("用户 "+user.getUsername()+" 注册成功");
        return userMapper.selectAllSalesman();
    }

}
